<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="me.yobol.greentable.commons.path.*" %>
<%@ page import="me.yobol.greentable.bean.IngredientBean"%>
<%@ page import="me.yobol.greentable.service.IngredientService"%>
<%@ page import="me.yobol.greentable.bean.CartCommodityBean" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>My Cart</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	
	<link rel="stylesheet" type="text/css" href="<%=CPath.cMain(request) %>"/>
  </head>
  
	<body>
	<%
  		String msg = (String)request.getParameter("msg");
  		if(msg != null)
		{
			if(msg.equals("IllegalOperationException"))
			{
	%>
				<script>alert("非法操作");</script>
	<%
			}else if(msg.equals("ept")){
	%>
				<script>alert("您没有选择任何商品");</script>
	<%
			}
		}
	%>
		<form action="<%=SPath.sCreateOrder(request) %>" method="post">
		<%
			List<CartCommodityBean> commodities = (List<CartCommodityBean>)(request.getSession().getAttribute("cart"));
			int customerId = (request.getSession().getAttribute("uId") == null) ? -1
					: (Integer)request.getSession().getAttribute("uId");
		%>
			<p>我的购物车：&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" value="下单" />
		<%
			if(!commodities.isEmpty()){
				for(CartCommodityBean cc : commodities){
					IngredientBean ig = IngredientService.getIngredientByIngredientId(cc.getIngredientId());
		%>
					<p>
						<img src="<%=ig.getIngredientImg()%>" width="64px" height="64px"/>
						<a href="<%=SPath.sGetIngredient(request,"?ingredientId=" + cc.getIngredientId()) %>">
							<%=ig.getIngredientName() %> : <%=ig.getIngredientPrice() %>
						</a>
						 * 
						<select name="cq">
							<option value ="1">1</option>
  							<option value ="2">2</option>
  							<option value="3">3</option>
  							<option value="4">4</option>
							<option value ="5">5</option>
  							<option value ="6">6</option>
						</select>
						<a href="<%=SPath.sDeleteCartCommodity(request, "?commodityId=" + cc.getCommodityId())%>">删除</a>
						<input type="checkbox" name="order" value="<%=cc.getCommodityId() %>"/>
					</p>
		<%
				}
			}
		%>
		</form>
	</body>
</html>
